# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class XiangmuItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    pass


class DoubanItem(scrapy.Item):
    title = scrapy.Field()
    uper_time = scrapy.Field()
    daoyan = scrapy.Field()
    zhuyan_list= scrapy.Field()
    type = scrapy.Field()
    all_time = scrapy.Field()
    diqu = scrapy.Field()
    photo = scrapy.Field()
    neirong = scrapy.Field()
    image_urls = scrapy.Field()

    def get_inset_sql_and_data(self):
        insert_sql = 'insert into douban_test(title,uper_time,daoyan,zhuyan_list,`type`,all_time,diqu,photo,neirong)VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s)'
        data = (self['title'],self['uper_time'],self['daoyan'],self['zhuyan_list'],self['type'],self['all_time'],self['diqu'],self['photo'],self['neirong'])
        return (insert_sql,data)
    # create table douban_test(
    #     id int primary key auto_increment,
    #     title varchar(50),
    #     uper_time varchar(50),
    #     daoyan varchar(50),
    #     zhuyan_list text,
    #     type varchar(50),
    #     all_time varchar(50),
    #     diqu varchar(50),
    #     photo text,
    #     neirong text)DEFAULT CHARSET = UTF8mb4;


class LeisuItem(scrapy.Item):
    source = scrapy.Field()
    round_num = scrapy.Field()
    time_list = scrapy.Field()
    host_team = scrapy.Field()
    score = scrapy.Field()
    client_team = scrapy.Field()
    year = scrapy.Field()

    def get_inset_sql_and_data(self):
        insert_sql = 'INSERT INTO leisu_test(source,round_num,time_list,host_team,score,client_team, `year`)' \
                     'VALUES (%s,%s,%s,%s,%s,%s, %s)'

        data = (self['source'],self['round_num'],self['time_list'],self['host_team'],self['score'],self['client_team'], self['year'])
        return (insert_sql, data)
    # CREATE TABLE leisu_test(id int primary key auto_increment, source varchar(20),
    #                           round_num varchar(10), time_list date, host_team varchar(20),
    #                           score varchar(10), client_team varchar(20), `year` char(10)) DEFAULT CHARSET=utf8mb4;
